// src/auth/auth.controller.ts
import { Controller, Post, Request, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { AuthService } from './auth.service';
import { Public } from '@/common/decorators/public.decorator';

@Controller('auth')
export class AuthController {
    constructor(private readonly authService: AuthService) { } // 确保构造函数注入正确

    @Public() // 使用 @Public() 装饰器排除 Token 验证
    @UseGuards(AuthGuard('local'))
    @Post('login')
    async login(@Request() req) {
        const token = await this.authService.generateToken(req.user);
        return { token };
    }
}